name: QA GitHub CI

on: [pull_request]

env:
  MAVEN_OPTS: -Xmx1024m -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3 -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

jobs:
  QA:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v4
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: 11
        distribution: 'temurin'
    - name: Set up Maven
      uses: stCarolas/setup-maven@v4.5
      with:
        maven-version: 3.9.5
    - name: Maven repository caching
      uses: actions/cache@v3
      with:
        path: ~/.m2/repository
        key: gs-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          gs-${{ runner.os }}-maven-
    - name: Build with Maven with full QA checks
      run: |
        mvn -B -ntp -U -T3 -fae -Dspotless.action=check -Dpom.fmt.action=verify -Dqa -DskipTests -Prelease -f src/pom.xml clean install
    - name: Build community modules without unit tests, but applying formatting checks
      run: |
        mvn -B -ntp -nsu -U -T4 -fae -Dspotless.action=check -Dpom.fmt.action=verify -DskipTests -Prelease,communityRelease -f src/community/pom.xml clean install
    - name: Remove SNAPSHOT jars from repository
      run: |
        find ~/.m2/repository -name "*SNAPSHOT*" -type d | xargs rm -rf {}

